import 'package:flutter/material.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/common/xindong_methods.dart';
import 'package:xindong/manager/xindong_hello_ctr.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/routes/tab_moments/controller/xindong_dongtai_actions_ctr.dart';
import 'package:xindong/routes/tab_moments/model/xindong_dongtai_class.dart';
import 'package:xindong/utils/xindong_image_util.dart';

class XinDongDongTaiListViewCellFooter extends StatelessWidget {
  final XinDongDongTaiClass model;
  final double paddingLeft;
  final Function(bool result) commentCallback; // 成功去刷新评论列表

  const XinDongDongTaiListViewCellFooter(
      {Key? key, required this.model, required this.commentCallback, required this.paddingLeft})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    const normalTextStyle = TextStyle(color: DZColors.placeholderColor, fontSize: 15, height: 1.2);
    return Container(
      height: kButtonHeight,
      padding: EdgeInsets.only(left: paddingLeft, right: kPaddingValue),
      child: Row(
        children: [
          GestureDetector(
            onTap: () => XinDongDongTaiActionsCtr.to.requestPraise(model),
            behavior: HitTestBehavior.opaque,
            child: GetBuilder<XinDongDongTaiActionsCtr>(
              id: XinDongDongTaiActions.like,
              builder: (comment) {
                if (comment.model != null && comment.model!.dy_id == model.dy_id) {
                  model.thumbsup = comment.model!.thumbsup;
                  model.isthumbsup = comment.model!.isthumbsup;
                }
                return Row(
                  children: [
                    ImageUtil.asset(
                      model.isthumbsup == 0 ? AssetsRes.ICON_DYNAMIC_ZAN_N : AssetsRes.ICON_DYNAMIC_ZAN_H,
                      width: 20,
                      height: 20,
                    ),
                    const SizedBox(width: 4),
                    Text(model.thumbsup, style: normalTextStyle),
                  ],
                );
              },
            ),
          ),
          const SizedBox(width: 20),
          GestureDetector(
            onTap: () => XinDongDongTaiActionsCtr.to.requestComment(model, sendResult: commentCallback),
            behavior: HitTestBehavior.opaque,
            child: GetBuilder<XinDongDongTaiActionsCtr>(
              id: XinDongDongTaiActions.comment,
              builder: (comment) {
                if (comment.model != null && comment.model!.dy_id == model.dy_id) {
                  model.comments = comment.model!.comments;
                }
                return Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    ImageUtil.asset(AssetsRes.ICON_DYNAMIC_COMMENT, width: 20, height: 20),
                    const SizedBox(width: 4),
                    Text("${model.comments}", style: normalTextStyle),
                  ],
                );
              },
            ),
          ),
          // const SizedBox(width: 20),
          // GestureDetector(
          //   onTap: () => XinDongDongTaiActionsController.to.requestDaShang(model),
          //   behavior: HitTestBehavior.opaque,
          //   child: GetBuilder<XinDongDongTaiActionsController>(
          //     id: XinDongDongTaiActions.dashang,
          //     builder: (comment) {
          //       if (comment.model != null && comment.model!.dy_id == model.dy_id) {
          //         model.comments = comment.model!.comments;
          //       }
          //       return Row(
          //         mainAxisSize: MainAxisSize.min,
          //         children: [
          //           ImageHelper.asset(AssetsRes.ICON_COIN_DASANG, width: 20, height: 20),
          //           const SizedBox(width: 4),
          //           const Text("打赏", style: normalTextStyle),
          //         ],
          //       );
          //     },
          //   ),
          // ),
          const Expanded(child: SizedBox()),
          GetBuilder<XinDongHelloCtr>(
            id: "${model.user_id}",
            builder: (controller) {
              return GestureDetector(
                onTap: () => XinDongHelloCtr.to.onSayHelloUser(model),
                behavior: HitTestBehavior.opaque,
                child: ImageUtil.asset(
                  model.canSayHello == true ? AssetsRes.BUTTON_DASHAN : AssetsRes.BUTTON_SIXIN,
                  width: 60,
                  height: 30,
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}
